package com.czl.module_service.fragment.assetHandle

import android.os.Bundle
import com.alibaba.android.arouter.facade.annotation.Route
import com.czl.base.base.BaseTabFragment
import com.czl.base.base.BaseTabViewModel
import com.czl.base.config.AppConstants
import com.czl.base.databinding.FragmentBaseTabBinding
import com.czl.base.event.LiveBusCenter
import com.czl.base.route.RouteCenter
import me.yokeyword.fragmentation.SupportFragment
import java.util.ArrayList

@Route(path = AppConstants.Router.Service.F_SERVICE_ASSET_HANDLE_FACILITY)
class AssetHandleFacilityFragment : BaseTabFragment<FragmentBaseTabBinding, BaseTabViewModel>() {

    override fun fragments(): List<SupportFragment> {
        return arrayListOf(
            RouteCenter.navigate(AppConstants.Router.Service.F_SERVICE_ASSET_HANDLE_FACILITY_INUSE, Bundle().apply {
                putSerializable("parentCompanyId",arguments?.getSerializable("parentCompanyId") as Int)
                putIntegerArrayList("facilityIdList", arguments?.getIntegerArrayList("facilityIdList") as ArrayList<Int>)
            }) as SupportFragment,

            RouteCenter.navigate(AppConstants.Router.Service.F_SERVICE_ASSET_HANDLE_FACILITY_STORE, Bundle().apply {
                putSerializable("parentCompanyId",arguments?.getSerializable("parentCompanyId") as Int)
                putIntegerArrayList("facilityIdList", arguments?.getIntegerArrayList("facilityIdList") as ArrayList<Int>)
            }) as SupportFragment,

            RouteCenter.navigate(AppConstants.Router.Service.F_SERVICE_ASSET_HANDLE_FACILITY_DAMAGE, Bundle().apply {
                putSerializable("parentCompanyId",arguments?.getSerializable("parentCompanyId") as Int)
                putIntegerArrayList("facilityIdList", arguments?.getIntegerArrayList("facilityIdList") as ArrayList<Int>)
            }) as SupportFragment,

            RouteCenter.navigate(AppConstants.Router.Service.F_SERVICE_ASSET_HANDLE_FACILITY_LOSS, Bundle().apply {
                putSerializable("parentCompanyId",arguments?.getSerializable("parentCompanyId") as Int)
                putIntegerArrayList("facilityIdList", arguments?.getIntegerArrayList("facilityIdList") as ArrayList<Int>)
            }) as SupportFragment
        )
    }

    override fun initData() {
        super.initData()
        viewModel.tabData.set("在用资产, 库存资产, 损坏记录, 盘亏资产")
        viewModel.tvTitle.set("选择处置资产")
    }

    override fun useBaseLayout(): Boolean {
        return true
    }

    override fun initViewObservable() {
        super.initViewObservable()
        LiveBusCenter.observeAddAssetHanldeFacilityEvent(this,{
            back()
        })
    }
}